package xyj.sparrow.scheduler.server.conf;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import xyj.sparrow.scheduler.server.NettyServer;
import xyj.sparrow.scheduler.util.RpcServiceImplUtil;


import javax.annotation.Resource;

@Configuration
@EnableConfigurationProperties(NettyServerConf.class)
public class AutoConfiguration {
    @Resource
    private NettyServerConf nettyServerConf;

    @Bean
    @DependsOn({"rpcServiceImplUtil","applicationContextUtil"})
    public NettyServer nettyServer() {

        return new NettyServer(this.nettyServerConf.getPort());
    }

    @Bean
    public RpcServiceImplUtil rpcServiceImplUtil() {
        return new RpcServiceImplUtil();
    }

}
